<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>注册页面</title>
</head>
<body>
    <form>
      <p>
        <lable>用户名称</lable><input type="text" name="username" />
      </p>
      <p>
        <lable>用户密码</lable><input type="password" name="password" />
      </p>
      <p>
        <lable>电话号码</lable><input type="text" name="tel" />
      </p>
      <p>
        <input type="button" value="点击注册" id="btn_submit">
      </p>
    </form>
    <!--引入jQuery依赖-->
    <script type="text/javascript" src="js/jquery-3.6.0.min.js"></script>
    <script type="text/javascript">
        $(function () {
            //给按钮绑定点击事件
            $("#btn_submit").click(function () {
                var username = $("input[name=username]").val();
                var password = $("input[name=password]").val();
                var tel = $("input[name=tel]").val();
                //传递的参数 key value 普通表单传递
                var user = {username:username,password:password,tel:tel};
                 $.ajax({
                     url:"/register",
                     type:"post",
                     data:JSON.stringify(user),//提交的是JSON数据
                     contentType:"application/json;charset=utf-8",
                     dataType:"json",
                     headers:{
                        token:"2020000001"
                     },
                     success:function (res) {
                          console.log(res)
                     }
                 })
            });
        })
    </script>
</body>
</html>